package cn.itcast.bos.mq;

import java.io.UnsupportedEncodingException;

import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageListener;

import org.springframework.stereotype.Service;

import cn.itcast.bos.utils.SmsUtils;

@Service("smsConsumer")
public class SmsConsumer implements MessageListener {

	@Override
	public void onMessage(Message message) {
		MapMessage mapMessage = (MapMessage) message;
		// 调服务Sms发送信息
		 //results;
		try {
			//String	results = SmsUtils.sendSmsByHTTP(mapMessage.getString("telephone"),mapMessage.getString("msg"));
			String results = "000/XXXX";
			if (results.startsWith("000")) {
				System.out.println("验证码信息已发送");
				System.out.println("电话"+mapMessage.getString("telephone")+"验证码"+mapMessage.getString("msg"));

			} else {
				throw new RuntimeException("失败" + results);
			}
		
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		//注释代码抽取项目
		
		// 判断返回值是否为000
		

		
	}

}